<?php
/**
 * Description of ArticleAction
 *
 * @author Alen
 * @since 1.0.0 2014-3-22 by sutroon
 */
class MediaAction extends ApiAction {
    
    //put your code here
    public function  index(){
        $biz=new SoBizMedia();
        $fid=  request_numeric('fid');
        $dataset=$biz->select_arrayset('ParentID='.$fid, '*');
        if(!$dataset) exit ();
        echo '{"total":'.count($dataset).',"rows":'.  json_encode($dataset).'}';
    }
    
    public function save(){
        $biz=new SoBizMedia();
        $msg=$biz->save();
        echo $this->get_json_fmt_result($msg);
    }
    public function remove(){        
        $biz=new SoBizMedia();
        $msg=$biz->remove();
        echo $this->get_json_fmt_result($msg);
    }
    public function read_one(){
        $biz=new SoBizMedia();
        $id=request_numeric('id');
        $dataset=$biz->read_one($id);
        if($dataset){
            $arr=array('id'=>$id,'title'=>$dataset['Title'],'content'=>$dataset['Content']);
            echo json_encode($arr);
        }
    }
    public function set_state(){        
        $biz=new SoBizMedia();
        $msg=$biz->update_records('State='.request_numeric('state'), 'ID='.request_numeric('id'));
        echo $this->get_json_fmt_result($msg);
    }
}
